home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / c / sozobon / sozlib15.zoo / sozdistr / include / xdlibs / file.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-11  |  11.4 KB  |  394 lines

  1. /* @(#)file.h, XdLibs MiNT support
  2.  
  3.     XdLibs - MiNT support
  4.     file.h
  5.     MiNT: sort of fcntl.h & ioctl.h 
  6.     constants and structures
  7.     used in MiNT Functions Dcntl() and Fcntl(), Fopen() etc
  8.  
  9.     see filesys.h for filesystems and device drivers
  10. */
  11.  
  12. #ifndef _file_h
  13. #define _file_h
  14.  
  15.  
  16. /* structure for getxattr */
  17.  
  18. typedef struct xattr {
  19.     unsigned short    mode;
  20. /* file types */
  21. #define S_IFMT    0170000        /* mask to select file type */
  22. #define S_IFCHR    0020000        /* BIOS special file */
  23. #define S_IFDIR    0040000        /* directory file */
  24. #define S_IFREG 0100000        /* regular file */
  25. #define S_IFIFO    0120000        /* FIFO */
  26. #define S_IFMEM    0140000        /* memory region or process */
  27. #define S_IFLNK    0160000        /* symbolic link */
  28.  
  29. /* special bits: setuid, setgid, sticky bit */
  30. #define S_ISUID    04000
  31. #define S_ISGID 02000
  32. #define S_ISVTX    01000
  33.  
  34. /* file access modes for user, group, and other*/
  35. #define S_IRUSR    0400
  36. #define S_IWUSR 0200
  37. #define S_IXUSR 0100
  38. #define S_IRGRP 0040
  39. #define S_IWGRP    0020
  40. #define S_IXGRP    0010
  41. #define S_IROTH    0004
  42. #define S_IWOTH    0002
  43. #define S_IXOTH    0001
  44. #define DEFAULT_DIRMODE (0777)
  45. #define DEFAULT_MODE    (0666)
  46.     long    index;
  47.     unsigned short    dev;
  48.     unsigned short    rdev;        /* "real" device */
  49.     unsigned short    nlink;
  50.     unsigned short    uid;
  51.     unsigned short    gid;
  52.     long    size;
  53.     long    blksize;
  54.     long    nblocks;
  55.     unsigned short    mtime, mdate;
  56.     unsigned short    atime, adate;
  57.     unsigned short    ctime, cdate;
  58.     unsigned short    attr;
  59. /* defines for TOS attribute bytes */
  60. #ifndef FA_RDONLY
  61. #define           FA_RDONLY           0x01
  62. #define           FA_HIDDEN           0x02
  63. #define           FA_SYSTEM           0x04
  64. #define           FA_LABEL               0x08
  65. #define           FA_DIR               0x10
  66. #define           FA_CHANGED           0x20
  67. #endif
  68.     short    reserved2;
  69.     long    reserved3[2];
  70. } XATTR;
  71.  
  72.  
  73. struct flock {
  74.     short l_type;            /* type of lock */
  75. #define F_RDLCK        0
  76. #define F_WRLCK        1
  77. #define F_UNLCK        3
  78.     short l_whence;            /* SEEK_SET, SEEK_CUR, SEEK_END */
  79.     long l_start;            /* start of locked region */
  80.     long l_len;            /* length of locked region */
  81.     short l_pid;            /* pid of locking process
  82.                         (F_GETLK only) */
  83. };
  84.  
  85.  
  86. /* flags for Fopen() modes, with MiNT > 0.9 
  87.     Fopen() replaces Fcreate() */
  88.  
  89. #define O_USER        0x0fff    /* isolates user-settable flag bits */
  90. #define O_RWMODE      0x03    /* isolates file read/write mode */
  91. #ifndef _FCNTL_H
  92. #    define O_RDONLY    0x00
  93. #    define O_WRONLY    0x01
  94. #    define O_RDWR    0x02
  95. #endif
  96.  
  97. #define O_EXEC        0x03    /* execute file; used by kernel only */
  98.     /* 0x04 is for future expansion */
  99. #ifndef _FCNTL_H
  100. #define O_APPEND    0x08    /* all writes go to end of file */
  101.  
  102. #define O_SHMODE    0x70    /* isolates file sharing mode */
  103. #    define O_COMPAT    0x00    /* compatibility mode */
  104. #    define O_DENYRW    0x10    /* deny both read and write access */
  105. #    define O_DENYW    0x20    /* deny write access to others */
  106. #    define O_DENYR    0x30    /* deny read access to others */
  107. #    define O_DENYNONE 0x40    /* don't deny any access to others */
  108.  
  109. #define O_NOINHERIT    0x80    /* private file (not passed to child) */
  110.  
  111. #define O_NDELAY    0x100    /* don't block for i/o on this file */
  112. #define O_CREAT        0x200    /* create file if it doesn't exist */
  113. #define O_TRUNC        0x400    /* truncate file to 0 bytes if it does exist */
  114. #define O_EXCL        0x800    /* fail open if file exists */
  115.  
  116. #define O_GLOBAL    0x1000    /* for opening a global file */
  117.  
  118. #endif
  119.  
  120. /* kernel mode bits -- the user can't set these! */
  121. #define O_TTY        0x2000
  122. #define O_HEAD        0x4000
  123. #define O_LOCK        0x8000
  124.  
  125. /* lseek() origins */
  126. #define    SEEK_SET    0        /* from beginning of file */
  127. #define    SEEK_CUR    1        /* from current location */
  128. #define    SEEK_END    2        /* from end of file */
  129.  
  130. /* The requests for Dpathconf() */
  131. #define DP_IOPEN    0    /* internal limit on # of open files */
  132. #define DP_MAXLINKS    1    /* max number of hard links to a file */
  133. #define DP_PATHMAX    2    /* max path name length */
  134. #define DP_NAMEMAX    3    /* max length of an individual file name */
  135. #define DP_ATOMIC    4    /* # of bytes that can be written atomically */
  136. #define DP_TRUNC    5    /* file name truncation behavior */
  137. #    define    DP_NOTRUNC    0    /* long filenames give an error */
  138. #    define    DP_AUTOTRUNC    1    /* long filenames truncated */
  139. #    define    DP_DOSTRUNC    2    /* DOS truncation rules in effect */
  140. #define DP_CASE        6
  141. #    define    DP_CASESENS    0    /* case sensitive */
  142. #    define    DP_CASECONV    1    /* case always converted */
  143. #    define    DP_CASEINSENS    2    /* case insensitive, preserved */
  144. #define DP_MODEATTR        7
  145. #    define    DP_ATTRBITS    0x000000ffL    /* mask for valid TOS attribs */
  146. #    define    DP_MODEBITS    0x000fff00L    /* mask for valid Unix file modes */
  147. #    define    DP_FILETYPS    0xfff00000L    /* mask for valid file types */
  148. #    define    DP_FT_DIR    0x00100000L    /* directories (always if . is there) */
  149. #    define    DP_FT_CHR    0x00200000L    /* character special files */
  150. #    define    DP_FT_BLK    0x00400000L    /* block special files, currently unused */
  151. #    define    DP_FT_REG    0x00800000L    /* regular files */
  152. #    define    DP_FT_LNK    0x01000000L    /* symbolic links */
  153. #    define    DP_FT_SOCK    0x02000000L    /* sockets, currently unused */
  154. #    define    DP_FT_FIFO    0x04000000L    /* pipes */
  155. #    define    DP_FT_MEM    0x08000000L    /* shared memory or proc files */
  156. #define DP_XATTRFIELDS    8
  157. #    define    DP_INDEX    0x0001
  158. #    define    DP_DEV        0x0002
  159. #    define    DP_RDEV        0x0004
  160. #    define    DP_NLINK    0x0008
  161. #    define    DP_UID        0x0010
  162. #    define    DP_GID        0x0020
  163. #    define    DP_BLKSIZE    0x0040
  164. #    define    DP_SIZE        0x0080
  165. #    define    DP_NBLOCKS    0x0100
  166. #    define    DP_ATIME    0x0200
  167. #    define    DP_CTIME    0x0400
  168. #    define    DP_MTIME    0x0800
  169. #define DP_MAXREQ    8    /* highest legal request */
  170.  
  171. /* Dpathconf and Sysconf return this when a value is not limited
  172.    (or is limited only by available memory) */
  173.  
  174. #define UNLIMITED    0x7fffffffL
  175.  
  176.  
  177. /* constants for Fcntl calls */
  178. #define F_DUPFD        0        /* handled by kernel */
  179. #define F_GETFD        1        /* handled by kernel */
  180. #define F_SETFD        2        /* handled by kernel */
  181. #    define FD_CLOEXEC    1    /* close on exec flag */
  182.  
  183. #define F_GETFL        3        /* handled by kernel */
  184. #define F_SETFL        4        /* handled by kernel */
  185. #define F_GETLK        5
  186. #define F_SETLK        6
  187. #define F_SETLKW    7
  188.  
  189. /* more constants for various Fcntl's */
  190.     /* basic file operations    */
  191. #define FSTAT        (('F'<< 8) | 0)        /* handled by kernel */
  192. #define FIONREAD    (('F'<< 8) | 1)
  193. #define FIONWRITE    (('F'<< 8) | 2)
  194. #define FUTIME        (('F'<< 8) | 3)    /* for use by Dcntl() too    */
  195. #define FTRUNCATE    (('F'<< 8) | 4)    /* for use by Dcntl() too    */
  196. #define FIOEXCEPT    (('F'<< 8) | 5)
  197.     /* basic tty related calls    */
  198. #define TIOCGETP    (('T'<< 8) | 0)
  199. #define TIOCSETN    (('T'<< 8) | 1)
  200. #define TIOCGETC    (('T'<< 8) | 2)
  201. #define TIOCSETC    (('T'<< 8) | 3)
  202. #define TIOCGLTC    (('T'<< 8) | 4)
  203. #define TIOCSLTC    (('T'<< 8) | 5)
  204. #define TIOCGPGRP    (('T'<< 8) | 6)
  205. #define TIOCSPGRP    (('T'<< 8) | 7)
  206. #define TIOCFLUSH    (('T'<< 8) | 8)
  207. #define TIOCSTOP    (('T'<< 8) | 9)
  208. #define TIOCSTART    (('T'<< 8) | 10)
  209. #define TIOCGWINSZ    (('T'<< 8) | 11)
  210. #define TIOCSWINSZ    (('T'<< 8) | 12)
  211. #define TIOCGXKEY    (('T'<< 8) | 13)
  212. #define TIOCSXKEY    (('T'<< 8) | 14)
  213. #define TIOCIBAUD    (('T'<< 8) | 18)
  214. #define TIOCOBAUD    (('T'<< 8) | 19)
  215. #define TIOCCBRK    (('T'<< 8) | 20)
  216. #define TIOCSBRK    (('T'<< 8) | 21)
  217. #define TIOCGFLAGS    (('T'<< 8) | 22)    /* see TF_ constants/flags    */
  218. #define TIOCSFLAGS    (('T'<< 8) | 23)    /* see TF_ constants/flags    */
  219. #define TIOCOUTQ    (('T'<< 8) | 24)
  220. #define TIOCSETP    (('T'<< 8) | 25)
  221. #define TIOCHPCL    (('T'<< 8) | 26)
  222. #define TIOCCAR        (('T'<< 8) | 27)
  223. #define TIOCNCAR    (('T'<< 8) | 28)
  224. #define TIOCWONLINE    (('T'<< 8) | 29)
  225. #define TIOCSFLAGSB    (('T'<< 8) | 30)
  226. #define TIOCGSTATE    (('T'<< 8) | 31)
  227. #define TIOCSSTATEB    (('T'<< 8) | 32)
  228. #define TIOCGVMIN    (('T'<< 8) | 33)
  229. #define TIOCSVMIN    (('T'<< 8) | 34)
  230. /* extended tty Fcntls    */
  231.     /* sorry - missing    */
  232.  
  233. /* cursor control Fcntls:
  234.  * NOTE THAT THESE MUST BE TOGETHER
  235.  */
  236. #define TCURSOFF    (('c'<< 8) | 0)
  237. #define TCURSON        (('c'<< 8) | 1)
  238. #define TCURSBLINK    (('c'<< 8) | 2)
  239. #define TCURSSTEADY    (('c'<< 8) | 3)
  240. #define TCURSSRATE    (('c'<< 8) | 4)
  241. #define TCURSGRATE    (('c'<< 8) | 5)
  242.  
  243. /* process stuff */
  244. #define PPROCADDR    (('P'<< 8) | 1)
  245. #define PBASEADDR    (('P'<< 8) | 2)
  246. #define PCTXTSIZE    (('P'<< 8) | 3)
  247. #define PSETFLAGS    (('P'<< 8) | 4)
  248. #define PGETFLAGS    (('P'<< 8) | 5)
  249. #define PTRACESFLAGS    (('P'<< 8) | 6)
  250. #define PTRACEGFLAGS    (('P'<< 8) | 7)
  251. #    define    P_ENABLE    (1 << 0)    /* enable tracing */
  252. #ifdef NOTYETDEFINED
  253. #    define    P_DOS        (1 << 1)    /* trace DOS calls - unimplemented */
  254. #    define    P_BIOS        (1 << 2)    /* trace BIOS calls - unimplemented */
  255. #    define    P_XBIOS        (1 << 3)    /* trace XBIOS calls - unimplemented */
  256. #endif
  257.  
  258. #define PTRACEGO    (('P'<< 8) | 8)    /* these 4 must be together */
  259. #define PTRACEFLOW    (('P'<< 8) | 9)
  260. #define PTRACESTEP    (('P'<< 8) | 10)
  261. #define PTRACE11    (('P'<< 8) | 11)
  262. #define PLOADINFO    (('P'<< 8) | 12)
  263. #define    PFSTAT        (('P'<< 8) | 13)
  264.  
  265. #define SHMGETBLK    (('M'<< 8) | 0)
  266. #define SHMSETBLK    (('M'<< 8) | 1)
  267.  
  268.  
  269. struct ploadinfo {
  270.     /* passed */
  271.     short fnamelen;
  272.     /* returned */
  273.     char *cmdlin, *fname;
  274. };
  275.  
  276.  
  277. /* terminal control constants (tty.sg_flags) */
  278. #define T_CRMOD        0x0001
  279. #define T_CBREAK    0x0002
  280. #define T_ECHO        0x0004
  281. /* #define T_XTABS    0x0008  unimplemented*/
  282. #define T_RAW        0x0010
  283. /* #define T_LCASE    0x0020  unimplemented */
  284.  
  285. #define T_NOFLSH    0x0040        /* don't flush buffer when signals
  286.                                    are received */
  287. #define T_TOS        0x0080
  288. #define T_TOSTOP    0x0100
  289. #define T_XKEY        0x0200        /* Fread returns escape sequences for
  290.                                    cursor keys, etc. */
  291. #define T_ECHOCTL    0x0400        /* echo ctl chars as ^x */
  292. /* 0x0800 still available */
  293.  
  294. /* some TF_ flags : flags for TIOC[GS]FLAGS */
  295. #define TF_CAR        0x800        /* nonlocal mode, require carrier */
  296. #define TF_NLOCAL    TF_CAR
  297. #define TF_BRKINT    0x80        /* allow breaks interrupt (like ^C) */
  298.  
  299. #define TF_STOPBITS 0x0003
  300. #define TF_1STOP   0x0001 /* 1 Stoppbit */
  301. #define TF_15STOP  0x0002 /* 1.5 Stoppbit */
  302. #define    TF_2STOP   0x0003 /* 2 Stoppbit */
  303. #define TF_CHARBITS 0x000C
  304. #define TF_8BIT    0x0 /* 8 Bit */
  305. #define TF_7BIT    0x4
  306. #define TF_6BIT    0x8
  307. #define TF_5BIT    0xC /* 5 Bit */
  308. #define TF_FLAGS 0xF000
  309. #define T_TANDEM 0x1000 /* Xon/Xoff */
  310. #define T_RTSCTS 0x2000 /* RTS/CTS  */
  311. #define T_EVENP  0x4000 /* even  */
  312. #define T_ODDP   0x8000 /* odd  */
  313.  
  314. /* the following are terminal status flags (tty.state) */
  315. /* (the low byte of tty.state indicates a part of an escape sequence still
  316.  * hasn't been read by Fread, and is an index into that escape sequence)
  317.  */
  318. #define TS_ESC        0x00ff
  319. #define TS_BLIND    0x800        /* tty is `blind' i.e. has no carrier
  320.                        (cleared in local mode) */
  321. #define TS_HOLD        0x1000        /* hold (e.g. ^S/^Q) */
  322. #define TS_HPCL        0x4000        /* hang up on close */
  323. #define TS_COOKED    0x8000        /* interpret control chars */
  324.  
  325. /* structures for terminals */
  326. struct tchars {
  327.     char t_intrc;
  328.     char t_quitc;
  329.     char t_startc;
  330.     char t_stopc;
  331.     char t_eofc;
  332.     char t_brkc;
  333. };
  334.  
  335. struct ltchars {
  336.     char t_suspc;
  337.     char t_dsuspc;
  338.     char t_rprntc;
  339.     char t_flushc;
  340.     char t_werasc;
  341.     char t_lnextc;
  342. };
  343.  
  344. struct sgttyb {
  345.     char sg_ispeed;
  346.     char sg_ospeed;
  347.     char sg_erase;
  348.     char sg_kill;
  349.     unsigned short sg_flags;
  350. };
  351.  
  352. struct winsize {
  353.     short    ws_row;
  354.     short    ws_col;
  355.     short    ws_xpixel;
  356.     short    ws_ypixel;
  357. };
  358.  
  359. struct xkey {
  360.     short    xk_num;
  361.     char    xk_def[8];
  362. };
  363.  
  364.  
  365.  
  366. /* Dcntl constants and types */
  367. /* for FUTIME and FTRUNCATE see Fcntl() defines */
  368.  
  369. #define DEV_NEWTTY    0xde00
  370. #define DEV_NEWBIOS    0xde01
  371. #define DEV_INSTALL    0xde02
  372.  
  373. #define FS_INSTALL    0xf001  /* let the kernel know about the file system */
  374. #define FS_MOUNT      0xf002  /* make a new directory for a file system */
  375. #define FS_UNMOUNT    0xf003  /* remove a directory for a file system */
  376. #define FS_UNINSTALL  0xf004  /* remove a file system from the list */
  377.  
  378. struct _mutimbuf {
  379.     unsigned short actime, acdate;    /* GEMDOS format */
  380.     unsigned short modtime, moddate;
  381. };
  382.  
  383.  
  384. /* various fields for the "rdev" device numbers */
  385. #define BIOS_DRIVE_RDEV     0x0000
  386. #define BIOS_RDEV    0x0100
  387. #define FAKE_RDEV    0x0200
  388. #define PIPE_RDEV    0x7e00
  389. #define UNK_RDEV    0x7f00
  390. #define PROC_RDEV_BASE    0xa000
  391.  
  392.  
  393. #endif /* _file_h */
  394.